﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MOMKeLABS.Controls.Window
{
    public partial class WindowHeader : UserControl
    {
        public delegate void DragStartHandler(Object sender, MouseButtonEventArgs args);

        public event DragStartHandler DragStartEvent;

        public static readonly DependencyProperty WindowHeaderIconProperty =
            DependencyProperty.Register(
            "WindowHeaderIcon", typeof(string),
            typeof(WindowHeader), null);

        public static readonly DependencyProperty TitleTextProperty =
            DependencyProperty.Register(
            "TitleText", typeof(string),
            typeof(WindowHeader), new PropertyMetadata(null, new PropertyChangedCallback(OnTitleTextPropertyChanged)));

        public static readonly DependencyProperty IsDraggingProperty =
            DependencyProperty.Register(
            "IsDragging", typeof(bool),
            typeof(WindowHeader), new PropertyMetadata(false, new PropertyChangedCallback(OnIsDraggingPropertyChanged)));

        public string WindowHeaderIcon
        {
            get
            {
                return (string)GetValue(WindowHeaderIconProperty);
            }

            set
            {
                SetValue(WindowHeaderIconProperty, value);
            }
        }

        public bool IsDragging
        {
            get
            {
                return (bool)GetValue(IsDraggingProperty);
            }

            set
            {
                SetValue(IsDraggingProperty, value);
            }
        }

        public string TitleText
        {
            get
            {
                return (string)GetValue(TitleTextProperty);
            }

            set
            {
                SetValue(TitleTextProperty, value);
            }
        }

        private static void OnIsDraggingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {

        }



        private static void OnTitleTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // nothing to do yet
        }


        public WindowHeader()
        {
            InitializeComponent();

            this.DataContext = this;

        }

        private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (DragStartEvent != null)
            {
                DragStartEvent(sender, e);
                this.IsDragging = true;

            }
        }
    }
}
